package svc

import (
	"user/internal/config"

	"github.com/zeromicro/go-zero/core/stores/redis"
	"github.com/zeromicro/go-zero/core/stores/sqlx"
)

const (
	TIME_FORMAT = "2006-01-02 15:04:05"
)

type ServiceContext struct {
	Config     config.Config
	SqlConn    sqlx.SqlConn
	RedisConn  *redis.Redis
	TimeFormat string
}

func NewServiceContext(c config.Config) *ServiceContext {
	conn := config.NewPostgre(c.DataBase)
	redisConn := config.NewRedis(c.Redis)
	return &ServiceContext{
		Config:     c,
		SqlConn:    conn,
		RedisConn:  redisConn,
		TimeFormat: TIME_FORMAT,
	}
}
